$(function  () {
    $.post(
        ipurl+'/user/getstu',
        function(result) {
            if(result.code == 200){
                var menulist = result.data.results;
                var menuhtml = '<option value="0"></option>';
                for(var i=0;i<menulist.length;i++){
                    menuhtml+='<option value="'+menulist[i].ID+'">';
                    menuhtml+=menulist[i].USERNAME;
                    menuhtml+='</option>';
                }
                $("#parent").html(menuhtml);
            }
        }
    );

    //班级ID
    var ccid = $.cookie("bccid");

    layui.use('form', function(){
        var form = layui.form();
        //监听提交
        form.on('submit(add)', function(data){
              var parentID = $("#parent").val();

              $.ajax({
                url: ipurl+'/cstu/add',
                data: {
                    cid:ccid,
                    mid:parentID
                },
                type: "POST",
                //dataType: "json",
                complete: function(data) {
                }
            });
            parent.location.reload(); 
            x_admin_close();
        });
    });

})
